//公共
import myHeader from "/pages/headerfoot/pages/header.vue"
//图标
import uIcons from "/uni_modules/uni-icons/components/uni-icons/uni-icons.vue";
//cache缓存
import Cache from '@/utils/cache.js';
//打帮赛方法
import hitmatchcommon from '@/common/hitmatchcommon.js';

export default {
	components: {
		myHeader,
		uIcons,
	},
	data() {
		return {
			make_id:'',//赛事
			informationfilling: '个人对战列表',
			frame: false, //弹出框
			list:[],//赛事项目列表 Recruit a team
		}
	},
	onLoad(options = '') {
		var that = this;
		console.log(options);
		if (options.id) {
			that.make_id = options.id;
			that.getMakeProjectListLib(); //获取项目
		}
	},
	//分享按钮
		onShareAppMessage(e='') {
			var that=this;
			let projectid='';//项目
			let index=0;//位数
			var project_name='打榜赛';
			var url='/pages/hitgame/pages/hitgameindex';
			if(e.target){
				projectid = e.target.dataset.projectid // 项目ID
				index = e.target.dataset.index // 项目ID
				var url=that.list[index].url;
				var project_name=that.list[index].project_name+'对战邀请';
				//type 1=单人对战  2=团队对战
				//initiator 发起人ID
				url=url+"&initiator="+Cache.get('user_id')+"&make="+that.make_id+"&type=1&code="+new Date().getTime()
				console.log(url);
			}
			 return {
			 	title: project_name,
			 	path: url,
			 	imageUrl: 'https://www.iiscchina.com/wp-content/uploads/2023/07/qtmf.png',
			 }
			 
		},
	methods: {
//弹出项目选择
		applybattle(type='') {
			var that = this;
			console.log(type);
			that.frame = true; //弹出框
		},
		//关闭弹出项目选择
		close() {
			var that = this;
			that.frame = false; //弹出框
		},
		//获取项目
		async getMakeProjectListLib() {
			var that = this;
			var data = {};
			data['make_id'] = that.make_id;
			data['make_user_id'] = Cache.get('user_id');
			hitmatchcommon.getMakeProjectListLibMethod(data).then(res => {
				if (res) {
					that.list = res; //获取项目
				}
			});
		},
	}
}